Pattern projection methods, which measure shapes using the principle of triangulation based on deformations of patterns by projecting a plurality of patterns of pattern light onto an object, and capturing an image of the object on which the pattern light images are projected, are known. Of these methods, a spatial coding method which binary-encodes a space by projecting stripe pattern light formed by alternately arranging bright and dark portions to have arbitrary widths is well known in the field of three-dimensional measurements, and products which adopt this method are commercially available.
The arrangement of a general apparatus for measuring a three-dimensional shape and the concept of a three-dimensional measurement will be described below with reference to FIG. 1. A three-dimensional measurement apparatus is generally configured by a projector 101 which irradiates on an object to be measured with a pattern, and a camera 102 which captures an image of the reflected pattern. The projector 101 projects stripe pattern light on an object 103 by alternately arranging bright and dark portions to have arbitrary widths. The stripe pattern light has a plurality of predetermined pattern shapes. Every time the stripe pattern light of a given pattern shape is projected, the camera 102 captures an image of that pattern to acquire it as image data. Let (X, Y, Z) be a boundary position between bright and dark portions on the object 103. Let (X1, Y1) be a principal point position of the projector 101 when the boundary position (X, Y, Z) and the projector 101 are coupled by a line. Likewise, let (X2, Y2) be a principal point position of the camera 102 when the boundary position (X, Y, Z) and camera 102 are coupled by a line. In this case, the principal point position (X2, Y2) of the camera 102 is a point calculated based on horizontal coordinates of an image sensor (for example, a CCD or CMOS) of the camera 102. The horizontal coordinates are determined by horizontal and vertical widths of the image sensor. For example, in case of an image sensor of 640×480, an x coordinate in the horizontal direction assumes a value ranging from 0 to 640, and a y coordinate in the vertical direction assumes a value ranging from 0 to 480. Likewise, the principal point position (X1, Y1) of the projector 101 is calculated based on horizontal coordinates of a light projection sensor. Also, the distance L between the projector 101 and camera 102 is the base length, which assumes a value determined based on the configuration conditions of the apparatus. The boundary position (X, Y, Z) on the object 103 can be calculated by the principle of triangulation from these parameters. By calculating boundary positions (X, Y, Z) for the entire surface of the object 103, a three-dimensional shape of the object 103 can be measured.
Next, the stripe pattern light shape will be described below. Stripe pattern light of a binary code called a gray code having a coding error resistance will be described below with reference to FIG. 2. A portion which is observed as black on a captured reflected pattern corresponds to “0”, and that which is observed as white corresponds to “1”. In a pattern 201, the entire pattern is divided into two regions, which are encoded as “1” and “0”. In a pattern 202, four regions of bright and dark portions are encoded as “1”, “0”, “0”, and “1”, and corresponding stripe pattern light is irradiated to capture an image of the corresponding pattern. Furthermore, in a pattern 203, eight regions are encoded as “1”, “0”, “0”, “1”, “1”, “0”, “0”, and “1”, and corresponding stripe pattern light is irradiated to capture an image of the corresponding pattern. In this way, since encoded region numbers are assigned to respective regions, the respective regions can be judged. The respective regions can be judged as (1, 1, 1), (1, 1, 0), (1, 0, 0), (1, 0, 1), (0, 0, 1), (0, 0, 0), (0, 1, 0), and (0, 1, 1). Since a space can be divided into eight regions using the three patterns of stripe pattern light in this manner, this spatial coding will be referred to as 3-bit spatial coding hereinafter. Then, the respective patterns of stripe pattern light shown in FIG. 2 will be respectively referred to as 1-bit stripe pattern light, 2-bit stripe pattern light, and 3-bit stripe pattern light hereinafter.
In order to perform a three-dimensional shape measurement in more detail, n patterns of stripe pattern light are irradiated while sequentially reducing regions of bright and dark portions in size. Then, by assigning region numbers obtained by dividing an irradiation region of the projector into 2n regions, the respective regions can be judged. In a three-dimensional measurement which uses 1024 divided regions, 10-bit spatial coding is attained.
A merit of the gray code lies in that even when a coding error occurs at a region boundary due to a shift or blur of stripe pattern light, such an error is merely judged as a neighboring region, and does not cause any coding error as a largely shifted region. For this reason, the spatial coding method using the gray code is popularly used.
In order to improve the precision in the three-dimensional measurement by the spatial coding method, a horizontal coordinate position x of a boundary between bright and dark portions (to be referred to as “boundary position” hereinafter) has to be determined from captured image data. The boundary position between bright and dark portions will be described below with reference to FIGS. 3A and 3B. FIGS. 3A and 3B are graphs when the ordinate plots luminance values of image data obtained by capturing an image of 2-bit stripe pattern light, and the abscissa plots the horizontal coordinates x. FIG. 3A shows ideal boundary positions. In FIG. 3A, since the bright and dark portions have different luminance values “1” and “0” at boundaries, the boundary positions between the bright and dark portions are uniquely determined, and positions a and b can be determined as boundary positions. However, in an actual measurement, a moderate change is observed in the vicinity of each boundary due to the influences of, for example, a blur of stripe pattern light, a reflectance of an object, and external light, as shown in FIG. 3B, and boundary positions cannot be uniquely determined, thus causing measurement errors.
In order to avoid such problem, a method which gives a reliability which indicates a measurement precision level to each measurement point, and does not use measured coordinates if the reliability of the coordinates is equal to or lower than a threshold is disclosed (for example, see Japanese Patent No. 3996560).
In the Japanese Patent No. 3996560, an object is irradiated with full-illumination light corresponding to a bright portion on the entire pattern and full-extinction light corresponding to a dark portion on the entire pattern in addition to stripe pattern light. The reliability is calculated as a ratio of a luminance difference of the stripe pattern light to that between the full-illumination light and full-extinction light. Then, only measurement points whose reliabilities exceed the threshold are output.
In the invention of the Japanese Patent No. 3996560, the luminance difference of the stripe pattern light has to be calculated. In order to precisely calculate the luminance difference, a luminance curve has to be calculated using luminance values of a plurality of pixels, resulting in high computation cost. A method of calculating a luminance difference by deciding sampling points in advance is available. However, in this case, respective sampling points have different reliabilities, and the reliabilities cannot be precisely reflected.